﻿using System.Data.SqlClient;
using NUnit.Framework;
using Pantry.Entity;
using Pantry.DataAccess;
namespace Pantry.UnitTest
{
    [TestFixture]
    public class TestAddressDao
    {
        [Test]
        public void TestReturnSearchValue_NullValue()
        { const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var address = new AddressSearch { Address = "", Postcode = "", Town = "" };
            var dataView = new AddressDao().ReturnSearchValue(address);
            Assert.AreEqual(null,dataView);            
        }
        [Test]
        public void TestReturnSearchValue_ValidValue()
        {
            const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var address = new AddressSearch { Address = "", Postcode = "04", Town = "" };
            var dataView =  new AddressDao().ReturnSearchValue(address);
            Assert.IsNotEmpty(dataView.Table.Rows.Count.ToString());
        }
        [Test]
        public void TestReturnSearchValue_FullValue()
        {
            const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var address = new AddressSearch { Address = "Quang Trung", Postcode = "04", Town = " Hà Đông" };
            var dataView = new AddressDao().ReturnSearchValue(address);
            Assert.IsNotEmpty(dataView.Table.Rows.Count.ToString());
        }
    }
}
